const path = require("path");

const resolve = dir => {
  return path.join(__dirname, dir);
};

module.exports = {
  devServer: {
    historyApiFallback: true,
    hot: true,
    inline: true,
    stats: {
      colors: true
    },
    port: 8181,
    proxy: {
      // 匹配代理的url
      "/api/": {
        // 目标服务器地址
        target: "http://localhost:8080",
        
        // 路径重写
        pathRewrite: {
          "^/api": "/"
        },
        changeOrigin: true
      }
    }
  },
  // 如果你不需要使用eslint，把lintOnSave设为false即可
  lintOnSave: false,
  chainWebpack: config => {
    config.resolve.alias
      .set("@", resolve("src")) // key,value自行定义，比如.set('@@', resolve('src/components'))
      .set("_c", resolve("src/components"));
  },
  // 打包时不生成.map文件
  productionSourceMap: false,
  css: {
    loaderOptions: {
      scss: {
        prependData: `@import "./src/assets/style/main.scss";`
      }
    }
  }
};
